<template>
  <div>
    <el-dropdown>
      <span class="el-dropdown-link">
        <span>{{ author }}</span>
        <i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item>
          我的消息
          <el-badge class="mark" :value="12" />
        </el-dropdown-item>

        <el-dropdown-item>基本信息</el-dropdown-item>
        <el-dropdown-item>修改密码</el-dropdown-item>

        <span @click="logout()">
          <el-dropdown-item>退出</el-dropdown-item>
        </span>

        <!--        <el-dropdown-item disabled>双皮奶</el-dropdown-item>-->
        <!--        <el-dropdown-item divided>蚵仔煎</el-dropdown-item>-->
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<style>
.el-dropdown-link {
  cursor: pointer;
  color: aliceblue;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.el-avatar--small {
  line-height: 0;
}
</style>

<script>
import { removeToken } from '@/utils/auth'

export default {
  name: 'DropDownMenu',
  props: {
    author: {
      type: String,
    },
  },
  data() {
    return {}
  },
  methods: {
    logout() {
      // console.log(this.$route.path)
      removeToken()
      this.$router.push('/login?redirect=' + this.$route.path)
    },
  },
}
</script>